//测试菲涅尔效果的像素着色器

#version 450
#extension GL_ARB_separate_shader_objects : enable

//输入-从顶点着色器
layout(location = 0) in vec3 vs_fs_normal;
layout(location = 1) in vec2 vs_fs_TexCoord;
layout(location = 2) in vec3 vs_fs_worldPosition;

//输出
layout(location = 0) out vec4 fColor;

//纹理
layout(binding = 9) uniform sampler2D ourTexture;

//UniformBuffer
layout(binding = 7) uniform SceneData {
	mat4 view;
	mat4 proj;
	vec4 lightDir;
	vec4 eyePosition;
} ub_SceneData;

void main()
{
	//视线方向
	vec3 EyeDir = ub_SceneData.eyePosition.xyz - vs_fs_worldPosition;
	
	//法线点乘视线
	float NdE = dot(normalize(vs_fs_normal),normalize(EyeDir));
	
	//菲涅尔系数
	float fresnel = 1.0 - NdE;
	
	//将菲涅尔系数做指数变化使得效果更明显
	fresnel = pow(fresnel,3);
	
	fColor = vec4(fresnel,fresnel,fresnel,1.0);
}
